/**
 * Copyright (C) 2018-2022
 * All rights reserved, Designed By www.yixiang.co
 * 注意：
 * 本软件为www.yixiang.co开发研制
 */
package com.avic.modules.system.service.mapper;

import com.avic.common.mapper.CoreMapper;
import com.avic.modules.system.domain.DictDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhangzikang
 * @date 2022-08-14
 */
@Repository
@Mapper
public interface DictDetailMapper extends CoreMapper<DictDetail> {

    @Select("<script>SELECT d.* from sys_dict_detail d LEFT JOIN sys_dict t on d.dict_id = t.id where 1=1 <if test = \"label !=null\" > and d.label LIKE concat('%', #{label}, '%') </if> <if test = \"dictName != ''||dictName !=null\" > AND t.name = #{dictName} order by t.sort asc</if></script>")
    List<DictDetail> selectDictDetailList(@Param("label") String label, @Param("dictName") String dictName);

    @Select("<script>SELECT d.* from sys_dict_detail d LEFT JOIN sys_dict t on d.dict_id = t.id where 1=1 <if test = \"dictId !=null\" > and t.id = #{dictId} </if><if test = \"value !=null\" > AND d.value = #{value} order by d.sort asc </if></script>")
    DictDetail selectDictDetailByLabel(@Param("dictId") Long dictId, @Param("value") String value);

    @Select("<script>SELECT * from sys_dict_detail where 1=1 <if test = \"dictId !=null\" > and dict_id = #{dictId} </if><if test = \"value !=null\" > AND value = #{value}</if></script>")
    DictDetail selectDictDetailLabel(@Param("dictId") Long dictId, @Param("value") String value);

    @Select("<script>SELECT d.* from sys_dict_detail d LEFT JOIN sys_dict t on d.dict_id = t.id where 1=1 <if test = \"dictId !=null\" > and t.id = #{dictId} </if></script>")
    List<DictDetail> selectDictDetailByDictId(@Param("dictId") Long dictId);
}
